local gangzao = fk.CreateSkill{
  name = "xiaobai__gangzao",

  dynamic_desc = function (self, player, lang)
    if player:getMark("@xiaobai__shujian") == 0 then
      return "xiaobai__gangzao"
    else
      return "xiaobai__gangzao_dynamics:"..player:getMark("@xiaobai__shujian")
    end
  end
}

Fk:loadTranslationTable {
  ["xiaobai__gangzao"] = "刚躁",
  [":xiaobai__gangzao"] = "你使用或打出牌后，你可以弃置一名手牌数为X的角色一张牌（X为你上次发动“疏谏”所满足的项数）。",
  [":xiaobai__gangzao_dynamics"] = "你使用或打出牌后，你可以弃置一名手牌数为 <font color=\"#E0DB2F\">{1}</font> 的角色一张牌（X为你上次发动“疏谏”所满足的项数）。",
  ["#xiaobai__gangzao_choose"] = "你可以弃置一名手牌数为 %arg 的角色一张牌",

  ["$xiaobai__gangzao1"] = "礼制不规，该罚！",
  ["$xiaobai__gangzao2"] = "奏疏检举？待吾整带观之。",
}

local gangzao_spec = {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(gangzao.name) then
      local x = player:getMark("@xiaobai__shujian")
      local room = player.room
      local targets = table.filter(room.alive_players, function (p)
        return p:getHandcardNum() == x
      end)
      if #targets > 0 then
          return true
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local x = player:getMark("@xiaobai__shujian")
    local targets = table.filter(room.alive_players, function (p)
      return p:getHandcardNum() == x and not p:isNude()
    end)
    local to = room:askToChoosePlayers(player, {
      min_num = 1,
      max_num = 1,
      targets = targets,
      skill_name = gangzao.name,
      prompt = "#xiaobai__gangzao_choose:::"..x,
      cancelable = true,
    })
    if #to > 0 then
        event:setCostData(self, {tos = to})
        return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to1 = event:getCostData(self).tos[1]
    local card = room:askToChooseCard(player, {
      target = to1,
      skill_name = gangzao.name,
      flag = "he",
    })
    room:throwCard(card, gangzao.name, to1, player)
  end
}
gangzao:addEffect(fk.CardUseFinished, gangzao_spec)
gangzao:addEffect(fk.CardRespondFinished, gangzao_spec)

return gangzao